package org.putrpctorest.service.impl.copy;

import java.util.Map;

import org.putrpctorest.container.Container;
import org.putrpctorest.expression.RestMethodEntryPoint;

public class ServiceInvokerImpl {
    // implements ServiceInvoker {

    Container container;

    public ServiceInvokerImpl(Container container) {
        this.container = container;
    }

    // @Override
    public Object invokeService(Map<String, Object> params, String methodName) throws Exception {
        return internalInvokeService(params, methodName, container);
    }

    // @Override
    public Container getContainer() {
        return container;
    }

    private Object internalInvokeService(Map<String, Object> params, String methodName, Container container)
            throws Exception {

        RestMethodEntryPoint restMethodEntryPoint = container.getRestMethodEntryPoint(methodName + ".entryPoint");

        return restMethodEntryPoint.invoke(params);

    }

}
